-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Typescript compatibility (#14)
* move javascript tests to their own directory * add basic typescript integration tests * remove build artifacts
- Loading branch information
1 parent
7f8791a
commit 8f87866
Showing
38 changed files
with
480 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
node_modules | ||
dist | ||
coverage | ||
integration-tests/jest/givens.tgz | ||
integration-tests/jest/package-lock.json | ||
integration-tests/mocha/givens.tgz | ||
integration-tests/mocha/package-lock.json | ||
integration-tests/jasmine/givens.tgz | ||
integration-tests/jasmine/package-lock.json | ||
integration-tests/javascript/jest/givens.tgz | ||
integration-tests/javascript/jest/package-lock.json | ||
integration-tests/javascript/mocha/givens.tgz | ||
integration-tests/javascript/mocha/package-lock.json | ||
integration-tests/javascript/jasmine/givens.tgz | ||
integration-tests/javascript/jasmine/package-lock.json | ||
integration-tests/typescript/jest/givens.tgz | ||
integration-tests/typescript/jest/package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
rm -rf node_modules | ||
rm -rf dist | ||
rm -rf coverage | ||
rm -rf integration-tests/jest/node_modules | ||
rm -f integration-tests/jest/givens.tgz | ||
rm -rf integration-tests/mocha/node_modules | ||
rm -f integration-tests/mocha/givens.tgz | ||
rm -rf integration-tests/jasmine/node_modules | ||
rm -f integration-tests/jasmine/givens.tgz | ||
|
||
rm -rf integration-tests/javascript/jest/node_modules | ||
rm -f integration-tests/javascript/jest/givens.tgz | ||
rm -rf integration-tests/javascript/mocha/node_modules | ||
rm -f integration-tests/javascript/mocha/givens.tgz | ||
rm -rf integration-tests/javascript/jasmine/node_modules | ||
rm -f integration-tests/javascript/jasmine/givens.tgz | ||
|
||
rm -rf integration-tests/typescript/jest/node_modules | ||
rm -f integration-tests/typescript/jest/givens.tgz |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
cd ./../../../ | ||
npm pack | ||
for f in *.tgz; do | ||
mv $f integration-tests/javascript/jasmine/givens.tgz | ||
done |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
cd ./../../../ | ||
npm pack | ||
for f in *.tgz; do | ||
mv $f integration-tests/javascript/jest/givens.tgz | ||
done |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
cd ./../../../ | ||
npm pack | ||
for f in *.tgz; do | ||
mv $f integration-tests/javascript/mocha/givens.tgz | ||
done |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
plugins: ["jest"], | ||
env: { | ||
jest: true | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
cd ./../../../ | ||
npm pack | ||
for f in *.tgz; do | ||
mv $f integration-tests/typescript/jest/givens.tgz | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
verbose: true, | ||
setupFilesAfterEnv: [ | ||
'givens/setup.js', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "givens-integration-tests-jest", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"test": "jest", | ||
"preinstall": "./build-givens.sh", | ||
"lint": "eslint test/**.*" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-plugin-jest": "^23.6.0", | ||
"givens": "file:givens.tgz", | ||
"jest": "^25.1.0" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
integration-tests/typescript/jest/test/__snapshots__/errors.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`illegal call location in test breaks 1`] = `"givens: cannot call givens from a test"`; | ||
|
||
exports[`with recursive given variables blows up 1`] = ` | ||
"givens: recursive variable recursive1 detected | ||
trace: recursive1 => recursive2 => recursive1" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import assert from 'assert'; | ||
import getGiven from 'givens'; | ||
|
||
const given = getGiven(); | ||
|
||
describe('illegal prop', () => { | ||
assert.throws( | ||
() => given('__props__', () => 'value'), | ||
(err) => err.message === 'givens: key "__props__" is not allowed', | ||
); | ||
|
||
it('does stuff', () => { | ||
expect(true); | ||
}); | ||
}); | ||
|
||
describe('illegal call location', () => { | ||
describe('in beforeEach method', () => { | ||
beforeEach(() => { | ||
assert.throws( | ||
() => given('test', () => 'foo'), | ||
(err) => err.message === 'givens: cannot call givens from a lifecycle hook', | ||
); | ||
}); | ||
|
||
it('breaks', () => {}); | ||
}); | ||
|
||
describe('in afterEach method', () => { | ||
afterEach(() => { | ||
assert.throws( | ||
() => given('test', () => 'foo'), | ||
(err) => err.message === 'givens: cannot call givens from a lifecycle hook', | ||
); | ||
}); | ||
|
||
it('breaks', () => {}); | ||
}); | ||
|
||
describe('in beforeAll method', () => { | ||
beforeAll(() => { | ||
assert.throws( | ||
() => given('test', () => 'foo'), | ||
(err) => err.message === 'givens: cannot call givens from a lifecycle hook', | ||
); | ||
}); | ||
|
||
it('breaks', () => {}); | ||
}); | ||
|
||
describe('in afterAll method', () => { | ||
afterAll(() => { | ||
assert.throws( | ||
() => given('test', () => 'foo'), | ||
(err) => err.message === 'givens: cannot call givens from a lifecycle hook', | ||
); | ||
}); | ||
|
||
it('breaks', () => {}); | ||
}); | ||
|
||
describe('in test', () => { | ||
it('breaks', () => { | ||
expect(() => given('test', () => 'foo')).toThrowErrorMatchingSnapshot(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('with recursive given variables', () => { | ||
given('recursive1', () => { | ||
const string1 = 'recursive1 => '; | ||
const string2 = given.recursive2; | ||
return string1 + string2; | ||
}); | ||
given('recursive2', () => { | ||
const string1 = 'recursive2 => '; | ||
const string2 = given.recursive1; | ||
return string1 + string2; | ||
}); | ||
given('nonRecursive', () => given.recursive1); | ||
|
||
it('blows up', () => { | ||
expect(() => given.nonRecursive).toThrowErrorMatchingSnapshot(); | ||
}); | ||
}); |
61 changes: 61 additions & 0 deletions
61
integration-tests/typescript/jest/test/given-default.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import assert from 'assert'; | ||
import getGiven from 'givens'; | ||
|
||
const given = getGiven(); | ||
|
||
describe('basic overriding behavior', () => { | ||
given('var1', () => 'initial value'); | ||
|
||
given('var2', () => `the value is: ${given.var1}`); | ||
|
||
it('has initial value', () => { | ||
expect(given.var2).toEqual('the value is: initial value'); | ||
}); | ||
|
||
describe('with new value', () => { | ||
given('var1', () => 'overridden value'); | ||
|
||
it('has overridden value', () => { | ||
expect(given.var2).toEqual('the value is: overridden value'); | ||
}); | ||
}); | ||
|
||
it('has initial value again', () => { | ||
expect(given.var2).toEqual('the value is: initial value'); | ||
}); | ||
}); | ||
|
||
describe('basic caching behavior', () => { | ||
given('var', () => ({ value: 'initial' })); | ||
given('random', () => Math.random()); | ||
|
||
test('it caches value', () => { | ||
given.var.value = 'new'; | ||
expect(given.var.value).toBe('new'); | ||
}); | ||
|
||
test('random cache test', () => { | ||
expect(given.random).toEqual(given.random); | ||
}); | ||
|
||
describe('with beforeEach', () => { | ||
beforeEach(() => { | ||
given.var.value = 'new'; | ||
}); | ||
|
||
test('it caches value', () => { | ||
expect(given.var.value).toBe('new'); | ||
}); | ||
}); | ||
|
||
describe('with afterEach', () => { | ||
afterEach(() => { | ||
assert.equal(given.var.value, 'new'); | ||
}); | ||
|
||
test('it caches value', () => { | ||
expect(given.var.value).toBe('initial'); | ||
given.var.value = 'new'; | ||
}); | ||
}); | ||
}); |
68 changes: 68 additions & 0 deletions
68
integration-tests/typescript/jest/test/given-typed.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import assert from 'assert'; | ||
import getGiven from 'givens'; | ||
|
||
interface myVars { | ||
var1: string; | ||
var2: string; | ||
var: { value: string }; | ||
random: number; | ||
} | ||
|
||
const given = getGiven<myVars>(); | ||
|
||
describe('basic overriding behavior', () => { | ||
given('var1', () => 'initial value'); | ||
|
||
given('var2', () => `the value is: ${given.var1}`); | ||
|
||
it('has initial value', () => { | ||
expect(given.var2).toEqual('the value is: initial value'); | ||
}); | ||
|
||
describe('with new value', () => { | ||
given('var1', () => 'overridden value'); | ||
|
||
it('has overridden value', () => { | ||
expect(given.var2).toEqual('the value is: overridden value'); | ||
}); | ||
}); | ||
|
||
it('has initial value again', () => { | ||
expect(given.var2).toEqual('the value is: initial value'); | ||
}); | ||
}); | ||
|
||
describe('basic caching behavior', () => { | ||
given('var', () => ({ value: 'initial' })); | ||
given('random', () => Math.random()); | ||
|
||
test('it caches value', () => { | ||
given.var.value = 'new'; | ||
expect(given.var.value).toBe('new'); | ||
}); | ||
|
||
test('random cache test', () => { | ||
expect(given.random).toEqual(given.random); | ||
}); | ||
|
||
describe('with beforeEach', () => { | ||
beforeEach(() => { | ||
given.var.value = 'new'; | ||
}); | ||
|
||
test('it caches value', () => { | ||
expect(given.var.value).toBe('new'); | ||
}); | ||
}); | ||
|
||
describe('with afterEach', () => { | ||
afterEach(() => { | ||
assert.equal(given.var.value, 'new'); | ||
}); | ||
|
||
test('it caches value', () => { | ||
expect(given.var.value).toBe('initial'); | ||
given.var.value = 'new'; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"strict": true | ||
} | ||
} |
Oops, something went wrong.