Add @mattwr18's code and fix linting

This commit is contained in:
Robert Schäfer 2018-12-21 00:03:57 +01:00
parent e58e228f0c
commit 6b216be05c
4 changed files with 39 additions and 31 deletions

View File

@ -4,6 +4,7 @@ module.exports = {
"env": {
"es6": true,
"node": true,
"jest/globals": true
},
"rules": {
"indent": [
@ -14,5 +15,6 @@ module.exports = {
"error",
"single"
]
}
},
"plugins": ["jest"]
};

View File

@ -66,9 +66,10 @@
"babel-eslint": "~10.0.1",
"babel-jest": "^23.6.0",
"chai": "~4.2.0",
"eslint": "~5.10.0",
"eslint": "^5.10.0",
"eslint-config-standard": "~12.0.0",
"eslint-plugin-import": "~2.14.0",
"eslint-plugin-jest": "^22.1.2",
"eslint-plugin-node": "~8.0.0",
"eslint-plugin-promise": "~4.0.1",
"eslint-plugin-standard": "~4.0.0",

View File

@ -1,42 +1,42 @@
import { request } from "graphql-request";
import server from "./server";
import { request } from 'graphql-request'
import server from './server'
describe("login", () => {
describe("asking for a `token`", () => {
describe("with valid email/password combination", () => {
xit("responds with a JWT token", () => {});
});
describe('login', () => {
describe('asking for a `token`', () => {
describe('with valid email/password combination', () => {
xit('responds with a JWT token', () => {})
})
describe("with a valid email but incorrect password", () => {
describe('with a valid email but incorrect password', () => {
beforeEach(() => {
// create a user in the database
});
xit('responds with "Wrong email/password combination"', () => {});
});
})
xit('responds with "Wrong email/password combination"', () => {})
})
describe("with a non-existing email", () => {
let getHost;
describe('with a non-existing email', () => {
let getHost
beforeEach(async () => {
const app = await server.start({ port: 0 });
const { port } = app.address();
getHost = () => `http://127.0.0.1:${port}`;
});
const email = "tom@bob.com";
const password = "jalksdf";
const app = await server.start({ port: 0 })
const { port } = app.address()
getHost = () => `http://127.0.0.1:${port}`
})
const mutation = `
mutation {
login(email:"asfasf@baldf.cm", password:"asdfasd"){
login(email:"user@example.com", password:"asdfasd"){
token
}
}`;
}`
it('responds with "Wrong email/password combination"', async () => {
const response = await request(getHost(), mutation);
expect(response).toBe({});
});
});
});
});
try {
await request(getHost(), mutation)
} catch (error) {
expect(error.response.errors[0].message).toEqual('Wrong email/password combination')
}
})
})
})
})

View File

@ -2728,6 +2728,11 @@ eslint-plugin-import@~2.14.0:
read-pkg-up "^2.0.0"
resolve "^1.6.0"
eslint-plugin-jest@^22.1.2:
version "22.1.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.1.2.tgz#1ea36cc3faedbdb788e702ca633d635ca14e91e8"
integrity sha512-jSPT4rVmNetkeCIyrvvOM0wJtgoUSbKHIUDoOGzIISsg51eWN/nISPNKVM+jXMMDI9oowbyapOnpKSXlsLiDpQ==
eslint-plugin-node@~8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-8.0.0.tgz#fb9e8911f4543514f154bb6a5924b599aa645568"
@ -2776,7 +2781,7 @@ eslint-visitor-keys@^1.0.0:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"
integrity sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==
eslint@~5.10.0:
eslint@^5.10.0:
version "5.10.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.10.0.tgz#24adcbe92bf5eb1fc2d2f2b1eebe0c5e0713903a"
integrity sha512-HpqzC+BHULKlnPwWae9MaVZ5AXJKpkxCVXQHrFaRw3hbDj26V/9ArYM4Rr/SQ8pi6qUPLXSSXC4RBJlyq2Z2OQ==