Skip to content

Commit

Permalink
feat: added test
Browse files Browse the repository at this point in the history
  • Loading branch information
LuXDAmore committed Dec 7, 2019
1 parent c03fce9 commit 554547d
Showing 1 changed file with 88 additions and 2 deletions.
90 changes: 88 additions & 2 deletions test/module.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Nuxt, Builder } from 'nuxt';
import { JSDOM } from 'jsdom';
import request from 'request-promise-native';
import getPort from 'get-port';
import config from '../example/nuxt.config';
Expand All @@ -22,7 +23,7 @@ const url = path => `http://localhost:${ port }${ path }`
;

describe(
'basic',
'nuxt',
() => {

beforeAll(
Expand Down Expand Up @@ -66,7 +67,92 @@ describe(
expect(
html
).toContain(
'Works!'
'NUXT Apis to file'
);

}
);

describe(
'data',
() => {

const getElement = async(
selector,
value
) => {

const html = await get(
'/'
)
, { window } = new JSDOM(
html
).window
, element = window.document.querySelector(
selector
)
, number = element.querySelector(
'.number'
)
, numberValue = number.textContent
;

expect(
element
).toBeDefined();

expect(
number
).toBeDefined();

expect(
numberValue
).toBeDefined();

expect(
parseInt(
numberValue
)
).toEqual(
value
);

}

test(
'comments',
async() => {

await getElement(
'.comments',
500,
);

}
);

test(
'comments',
async() => {

await getElement(
'.posts',
100,
);

}
);

test(
'users',
async() => {

await getElement(
'.users',
35,
);

}
);

}
Expand Down

0 comments on commit 554547d

Please sign in to comment.