Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript: Turn on noImplicityAny and fix a few type signatures #587

Merged
merged 5 commits into from
Feb 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/__tests__/does-not-exist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).doesNotExist()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -76,10 +76,14 @@ describe('assert.dom(...).doesNotExist()', () => {
'Unexpected Parameter: [object HTMLBodyElement]'
);

//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
Turbo87 marked this conversation as resolved.
Show resolved Hide resolved
expect(() => assert.dom(5).doesNotExist()).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).doesNotExist()).toThrow('Unexpected Parameter: true');
expect(() => assert.dom(undefined).doesNotExist()).toThrow('Unexpected Parameter: undefined');
//@ts-ignore
expect(() => assert.dom({}).doesNotExist()).toThrow('Unexpected Parameter: [object Object]');
//@ts-ignore
expect(() => assert.dom(document).doesNotExist()).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
6 changes: 5 additions & 1 deletion lib/__tests__/does-not-have-attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).doesNotHaveAttribute()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -84,16 +84,20 @@ describe('assert.dom(...).doesNotHaveAttribute()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).doesNotHaveAttribute('disabled')).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).doesNotHaveAttribute('disabled')).toThrow(
'Unexpected Parameter: true'
);
expect(() => assert.dom(undefined).doesNotHaveAttribute('disabled')).toThrow(
'Unexpected Parameter: undefined'
);
//@ts-ignore
expect(() => assert.dom({}).doesNotHaveAttribute('disabled')).toThrow(
'Unexpected Parameter: [object Object]'
);
//@ts-ignore
expect(() => assert.dom(document).doesNotHaveAttribute('disabled')).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
6 changes: 5 additions & 1 deletion lib/__tests__/does-not-have-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).doesNotHaveClass()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -118,14 +118,18 @@ describe('assert.dom(...).doesNotHaveClass()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).doesNotHaveClass('foo')).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).doesNotHaveClass('foo')).toThrow('Unexpected Parameter: true');
expect(() => assert.dom(undefined).doesNotHaveClass('foo')).toThrow(
'Unexpected Parameter: undefined'
);
//@ts-ignore
expect(() => assert.dom({}).doesNotHaveClass('foo')).toThrow(
'Unexpected Parameter: [object Object]'
);
//@ts-ignore
expect(() => assert.dom(document).doesNotHaveClass('foo')).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
6 changes: 5 additions & 1 deletion lib/__tests__/does-not-have-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).doesNotHaveStyle()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -91,16 +91,20 @@ describe('assert.dom(...).doesNotHaveStyle()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).doesNotHaveStyle({ opacity: 1 })).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).doesNotHaveStyle({ opacity: 1 })).toThrow(
'Unexpected Parameter: true'
);
expect(() => assert.dom(undefined).doesNotHaveStyle({ opacity: 1 })).toThrow(
'Unexpected Parameter: undefined'
);
//@ts-ignore
expect(() => assert.dom({}).doesNotHaveStyle({ opacity: 1 })).toThrow(
'Unexpected Parameter: [object Object]'
);
//@ts-ignore
expect(() => assert.dom(document).doesNotHaveStyle({ opacity: 1 })).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
12 changes: 9 additions & 3 deletions lib/__tests__/does-not-have-tagname.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).doesNotHaveTagName()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand All @@ -25,7 +25,7 @@ describe('assert.dom(...).doesNotHaveTagName()', () => {
});

describe('with HTMLElement', () => {
let element;
let element: Element;

beforeEach(() => {
document.body.innerHTML = '<section id="block">Section</section>\n';
Expand Down Expand Up @@ -114,34 +114,40 @@ describe('assert.dom(...).doesNotHaveTagName()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).doesNotHaveTagName('div')).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).doesNotHaveTagName('div')).toThrow('Unexpected Parameter: true');
expect(() => assert.dom(undefined).doesNotHaveTagName('div')).toThrow(
'Unexpected Parameter: undefined'
);
//@ts-ignore
expect(() => assert.dom({}).doesNotHaveTagName('div')).toThrow(
'Unexpected Parameter: [object Object]'
);
//@ts-ignore
expect(() => assert.dom(document).doesNotHaveTagName('div')).toThrow(
'Unexpected Parameter: [object Document]'
);
});

describe('invalid arguments to `doesNotHaveTagName`', () => {
let element;
let element: Element;

beforeEach(() => {
document.body.innerHTML = '<section id="block">Section</section>\n';
element = document.querySelector('#block');
});

test('passing a number to `doesNotHaveTagName` will throw an error', () => {
//@ts-ignore
expect(() => assert.dom(element).doesNotHaveTagName(1234)).toThrow(
'You must pass a string to "doesNotHaveTagName". You passed 1234'
);
});

test('passing an object to `doesNotHaveTagName` will throw an error', () => {
//@ts-ignore
expect(() => assert.dom(element).doesNotHaveTagName({})).toThrow(
'You must pass a string to "doesNotHaveTagName". You passed [object Object]'
);
Expand Down
8 changes: 6 additions & 2 deletions lib/__tests__/does-not-include-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).doesNotIncludeText()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand All @@ -25,7 +25,7 @@ describe('assert.dom(...).doesNotIncludeText()', () => {
});

describe('with HTMLElement', () => {
let element;
let element: Element;

beforeEach(() => {
document.body.innerHTML = '<h1 class="baz">foo</h1>bar';
Expand Down Expand Up @@ -114,14 +114,18 @@ describe('assert.dom(...).doesNotIncludeText()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).doesNotIncludeText('foo')).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).doesNotIncludeText('foo')).toThrow('Unexpected Parameter: true');
expect(() => assert.dom(undefined).doesNotIncludeText('foo')).toThrow(
'Unexpected Parameter: undefined'
);
//@ts-ignore
expect(() => assert.dom({}).doesNotIncludeText('foo')).toThrow(
'Unexpected Parameter: [object Object]'
);
//@ts-ignore
expect(() => assert.dom(document).doesNotIncludeText('foo')).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/does-not-match-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).doesNotMatchSelector()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down
6 changes: 5 additions & 1 deletion lib/__tests__/exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).exists()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -140,10 +140,14 @@ describe('assert.dom(...).exists()', () => {
'Unexpected Parameter: [object HTMLBodyElement]'
);

//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).exists()).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).exists()).toThrow('Unexpected Parameter: true');
expect(() => assert.dom(undefined).exists()).toThrow('Unexpected Parameter: undefined');
//@ts-ignore
expect(() => assert.dom({}).exists()).toThrow('Unexpected Parameter: [object Object]');
//@ts-ignore
expect(() => assert.dom(document).exists()).toThrow('Unexpected Parameter: [object Document]');
});
});
6 changes: 5 additions & 1 deletion lib/__tests__/has-any-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).hasAnyText()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -65,10 +65,14 @@ describe('assert.dom(...).hasAnyText()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).hasAnyText()).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).hasAnyText()).toThrow('Unexpected Parameter: true');
expect(() => assert.dom(undefined).hasAnyText()).toThrow('Unexpected Parameter: undefined');
//@ts-ignore
expect(() => assert.dom({}).hasAnyText()).toThrow('Unexpected Parameter: [object Object]');
//@ts-ignore
expect(() => assert.dom(document).hasAnyText()).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
7 changes: 6 additions & 1 deletion lib/__tests__/has-any-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).hasAnyValue()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -66,10 +66,15 @@ describe('assert.dom(...).hasAnyValue()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).hasAnyValue()).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).hasAnyValue()).toThrow('Unexpected Parameter: true');
//@ts-ignore
expect(() => assert.dom(undefined).hasAnyValue()).toThrow('Unexpected Parameter: undefined');
//@ts-ignore
expect(() => assert.dom({}).hasAnyValue()).toThrow('Unexpected Parameter: [object Object]');
//@ts-ignore
expect(() => assert.dom(document).hasAnyValue()).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
6 changes: 5 additions & 1 deletion lib/__tests__/has-attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).hasAttribute()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -239,14 +239,18 @@ describe('assert.dom(...).hasAttribute()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).hasAttribute('foo')).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).hasAttribute('foo')).toThrow('Unexpected Parameter: true');
expect(() => assert.dom(undefined).hasAttribute('foo')).toThrow(
'Unexpected Parameter: undefined'
);
//@ts-ignore
expect(() => assert.dom({}).hasAttribute('foo')).toThrow(
'Unexpected Parameter: [object Object]'
);
//@ts-ignore
expect(() => assert.dom(document).hasAttribute('foo')).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
6 changes: 5 additions & 1 deletion lib/__tests__/has-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).hasClass()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -113,10 +113,14 @@ describe('assert.dom(...).hasClass()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).hasClass('foo')).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).hasClass('foo')).toThrow('Unexpected Parameter: true');
expect(() => assert.dom(undefined).hasClass('foo')).toThrow('Unexpected Parameter: undefined');
//@ts-ignore
expect(() => assert.dom({}).hasClass('foo')).toThrow('Unexpected Parameter: [object Object]');
//@ts-ignore
expect(() => assert.dom(document).hasClass('foo')).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
6 changes: 5 additions & 1 deletion lib/__tests__/has-no-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).hasNoText()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -63,10 +63,14 @@ describe('assert.dom(...).hasNoText()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).hasNoText()).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).hasNoText()).toThrow('Unexpected Parameter: true');
expect(() => assert.dom(undefined).hasNoText()).toThrow('Unexpected Parameter: undefined');
//@ts-ignore
expect(() => assert.dom({}).hasNoText()).toThrow('Unexpected Parameter: [object Object]');
//@ts-ignore
expect(() => assert.dom(document).hasNoText()).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
6 changes: 5 additions & 1 deletion lib/__tests__/has-no-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).hasNoValue()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down Expand Up @@ -65,10 +65,14 @@ describe('assert.dom(...).hasNoValue()', () => {
});

test('throws for unexpected parameter types', () => {
//@ts-ignore -- These assertions are for JavaScript users who don't have type checking
expect(() => assert.dom(5).hasNoValue()).toThrow('Unexpected Parameter: 5');
//@ts-ignore
expect(() => assert.dom(true).hasNoValue()).toThrow('Unexpected Parameter: true');
expect(() => assert.dom(undefined).hasNoValue()).toThrow('Unexpected Parameter: undefined');
//@ts-ignore
expect(() => assert.dom({}).hasNoValue()).toThrow('Unexpected Parameter: [object Object]');
//@ts-ignore
expect(() => assert.dom(document).hasNoValue()).toThrow(
'Unexpected Parameter: [object Document]'
);
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/has-pseudo-element-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TestAssertions from '../helpers/test-assertions';

describe('assert.dom(...).hasPseudoElementStyle()', () => {
let assert;
let assert: TestAssertions;

beforeEach(() => {
assert = new TestAssertions();
Expand Down
Loading