From 1b8c2ff4f3f2e0a648bbff0c3db4a267034bdb3e Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Tue, 22 Nov 2016 12:37:14 -0500 Subject: [PATCH] pass assert into tests --- test/compiler/attribute-dynamic/_config.js | 4 +--- test/compiler/attribute-static-boolean/_config.js | 4 +--- test/compiler/autofocus/_config.js | 4 +--- .../binding-input-checkbox-deep-contextual/_config.js | 4 +--- test/compiler/binding-input-checkbox/_config.js | 4 +--- test/compiler/binding-input-text-contextual/_config.js | 4 +--- test/compiler/binding-input-text-deep-contextual/_config.js | 4 +--- test/compiler/binding-input-text-deep/_config.js | 4 +--- test/compiler/binding-input-text/_config.js | 4 +--- test/compiler/component-data-dynamic/_config.js | 4 +--- test/compiler/component-events-data/_config.js | 4 +--- test/compiler/component-events/_config.js | 4 +--- test/compiler/component-ref/_config.js | 3 +-- test/compiler/computed-values/_config.js | 4 +--- test/compiler/css/_config.js | 4 +--- test/compiler/custom-method/_config.js | 4 +--- test/compiler/default-data/_config.js | 2 -- test/compiler/each-block-containing-if/_config.js | 4 +--- test/compiler/each-block/_config.js | 4 +--- test/compiler/each-blocks-nested-b/_config.js | 2 +- test/compiler/each-blocks-nested/_config.js | 2 +- test/compiler/event-handler-custom/_config.js | 4 +--- test/compiler/event-handler-removal/_config.js | 4 +--- test/compiler/event-handler/_config.js | 4 +--- test/compiler/events-custom/_config.js | 4 +--- test/compiler/events-lifecycle/_config.js | 4 +--- test/compiler/hello-world/_config.js | 4 +--- test/compiler/if-block-else/_config.js | 4 +--- test/compiler/if-block/_config.js | 4 +--- test/compiler/inline-expressions/_config.js | 4 +--- test/compiler/lifecycle-events/_config.js | 4 +--- test/compiler/refs/_config.js | 4 +--- test/compiler/svg/_config.js | 4 +--- test/test.js | 4 ++-- 34 files changed, 34 insertions(+), 95 deletions(-) diff --git a/test/compiler/attribute-dynamic/_config.js b/test/compiler/attribute-dynamic/_config.js index e9738d114e..2b92e8ed60 100644 --- a/test/compiler/attribute-dynamic/_config.js +++ b/test/compiler/attribute-dynamic/_config.js @@ -1,8 +1,6 @@ -import * as assert from 'assert'; - export default { html: `
red
`, - test ( component, target ) { + test ( assert, component, target ) { const div = target.querySelector( 'div' ); assert.equal( div.style.color, 'red' ); diff --git a/test/compiler/attribute-static-boolean/_config.js b/test/compiler/attribute-static-boolean/_config.js index febfde0138..ee2dc5be2b 100644 --- a/test/compiler/attribute-static-boolean/_config.js +++ b/test/compiler/attribute-static-boolean/_config.js @@ -1,8 +1,6 @@ -import * as assert from 'assert'; - export default { html: ``, - test ( component, target ) { + test ( assert, component, target ) { const textarea = target.querySelector( 'textarea' ); assert.ok( textarea.readOnly ); } diff --git a/test/compiler/autofocus/_config.js b/test/compiler/autofocus/_config.js index d96d107362..6b772da7bd 100644 --- a/test/compiler/autofocus/_config.js +++ b/test/compiler/autofocus/_config.js @@ -1,8 +1,6 @@ -import * as assert from 'assert'; - export default { html: '', - test ( component, target, window ) { + test ( assert, component, target, window ) { component.set({ visible: true }); assert.equal( component.refs.input, window.document.activeElement ); } diff --git a/test/compiler/binding-input-checkbox-deep-contextual/_config.js b/test/compiler/binding-input-checkbox-deep-contextual/_config.js index 0fa0b8cfa2..35d7780690 100644 --- a/test/compiler/binding-input-checkbox-deep-contextual/_config.js +++ b/test/compiler/binding-input-checkbox-deep-contextual/_config.js @@ -1,5 +1,3 @@ -import * as assert from 'assert'; - export default { data: { items: [ @@ -9,7 +7,7 @@ export default { ] }, html: `

one

two

three

\n\n

1 completed

`, - test ( component, target, window ) { + test ( assert, component, target, window ) { const inputs = [ ...target.querySelectorAll( 'input' ) ]; assert.ok( inputs[0].checked ); diff --git a/test/compiler/binding-input-checkbox/_config.js b/test/compiler/binding-input-checkbox/_config.js index 634504a4d0..e12eb2ee48 100644 --- a/test/compiler/binding-input-checkbox/_config.js +++ b/test/compiler/binding-input-checkbox/_config.js @@ -1,11 +1,9 @@ -import * as assert from 'assert'; - export default { data: { foo: true }, html: `\n

true

`, - test ( component, target, window ) { + test ( assert, component, target, window ) { const input = target.querySelector( 'input' ); assert.equal( input.checked, true ); diff --git a/test/compiler/binding-input-text-contextual/_config.js b/test/compiler/binding-input-text-contextual/_config.js index df62feddd8..3f2d3f3fc0 100644 --- a/test/compiler/binding-input-text-contextual/_config.js +++ b/test/compiler/binding-input-text-contextual/_config.js @@ -1,5 +1,3 @@ -import * as assert from 'assert'; - export default { data: { items: [ @@ -9,7 +7,7 @@ export default { ] }, html: `

one

two

three

`, - test ( component, target, window ) { + test ( assert, component, target, window ) { const inputs = [ ...target.querySelectorAll( 'input' ) ]; const items = component.get( 'items' ); const event = new window.Event( 'input' ); diff --git a/test/compiler/binding-input-text-deep-contextual/_config.js b/test/compiler/binding-input-text-deep-contextual/_config.js index ada981c7a5..f24902a962 100644 --- a/test/compiler/binding-input-text-deep-contextual/_config.js +++ b/test/compiler/binding-input-text-deep-contextual/_config.js @@ -1,5 +1,3 @@ -import * as assert from 'assert'; - export default { data: { items: [ @@ -9,7 +7,7 @@ export default { ] }, html: `

one

two

three

`, - test ( component, target, window ) { + test ( assert, component, target, window ) { const inputs = [ ...target.querySelectorAll( 'input' ) ]; assert.equal( inputs[0].value, 'one' ); diff --git a/test/compiler/binding-input-text-deep/_config.js b/test/compiler/binding-input-text-deep/_config.js index a1c919c6ac..9911148a3c 100644 --- a/test/compiler/binding-input-text-deep/_config.js +++ b/test/compiler/binding-input-text-deep/_config.js @@ -1,5 +1,3 @@ -import * as assert from 'assert'; - export default { data: { user: { @@ -7,7 +5,7 @@ export default { } }, html: `\n

hello alice

`, - test ( component, target, window ) { + test ( assert, component, target, window ) { const input = target.querySelector( 'input' ); assert.equal( input.value, 'alice' ); diff --git a/test/compiler/binding-input-text/_config.js b/test/compiler/binding-input-text/_config.js index 572205dc29..ccbe234d12 100644 --- a/test/compiler/binding-input-text/_config.js +++ b/test/compiler/binding-input-text/_config.js @@ -1,11 +1,9 @@ -import * as assert from 'assert'; - export default { data: { name: 'world' }, html: `\n

hello world

`, - test ( component, target, window ) { + test ( assert, component, target, window ) { const input = target.querySelector( 'input' ); assert.equal( input.value, 'world' ); diff --git a/test/compiler/component-data-dynamic/_config.js b/test/compiler/component-data-dynamic/_config.js index 0e6ee0fdb1..514faf667e 100644 --- a/test/compiler/component-data-dynamic/_config.js +++ b/test/compiler/component-data-dynamic/_config.js @@ -1,5 +1,3 @@ -import * as assert from 'assert'; - export default { data: { bar: 'lol', @@ -7,7 +5,7 @@ export default { compound: 'piece of' }, html: `

foo: lol

\n

baz: 42 (number)

\n

qux: this is a piece of string

`, - test ( component, target ) { + test ( assert, component, target ) { component.set({ bar: 'wut', x: 3, diff --git a/test/compiler/component-events-data/_config.js b/test/compiler/component-events-data/_config.js index 9235660a98..f3763be9b1 100644 --- a/test/compiler/component-events-data/_config.js +++ b/test/compiler/component-events-data/_config.js @@ -1,7 +1,5 @@ -import * as assert from 'assert'; - export default { - test ( component, target, window ) { + test ( assert, component, target, window ) { const buttons = target.querySelectorAll( 'button' ); const click = new window.MouseEvent( 'click' ); diff --git a/test/compiler/component-events/_config.js b/test/compiler/component-events/_config.js index af5345aafa..eecdc8b03c 100644 --- a/test/compiler/component-events/_config.js +++ b/test/compiler/component-events/_config.js @@ -1,11 +1,9 @@ -import * as assert from 'assert'; - export default { data: { visible: true }, html: '

i am a widget

', // TODO comment should follow component... - test ( component ) { + test ( assert, component ) { let count = 0; component.on( 'widgetTornDown', function () { diff --git a/test/compiler/component-ref/_config.js b/test/compiler/component-ref/_config.js index d32cd98ded..09ce6f0f88 100644 --- a/test/compiler/component-ref/_config.js +++ b/test/compiler/component-ref/_config.js @@ -1,9 +1,8 @@ -import * as assert from 'assert'; import Widget from './Widget.html'; export default { html: '

i am a widget

', - test ( component ) { + test ( assert, component ) { const widget = component.refs.widget; assert.ok( widget instanceof Widget ); } diff --git a/test/compiler/computed-values/_config.js b/test/compiler/computed-values/_config.js index d63d3c0da1..179ebc2c9e 100644 --- a/test/compiler/computed-values/_config.js +++ b/test/compiler/computed-values/_config.js @@ -1,8 +1,6 @@ -import * as assert from 'assert'; - export default { html: '

1 + 2 = 3

\n

3 * 3 = 9

', - test ( component, target ) { + test ( assert, component, target ) { component.set({ a: 3 }); assert.equal( component.get( 'c' ), 5 ); assert.equal( component.get( 'cSquared' ), 25 ); diff --git a/test/compiler/css/_config.js b/test/compiler/css/_config.js index af689c32f6..f523d7755b 100644 --- a/test/compiler/css/_config.js +++ b/test/compiler/css/_config.js @@ -1,7 +1,5 @@ -import * as assert from 'assert'; - export default { - test ( component, target, window ) { + test ( assert, component, target, window ) { const [ control, test ] = target.querySelectorAll( 'p' ); assert.equal( window.getComputedStyle( control ).color, '' ); diff --git a/test/compiler/custom-method/_config.js b/test/compiler/custom-method/_config.js index a2a4882737..1586df8a79 100644 --- a/test/compiler/custom-method/_config.js +++ b/test/compiler/custom-method/_config.js @@ -1,8 +1,6 @@ -import * as assert from 'assert'; - export default { html: '\n\n

0

', - test ( component, target, window ) { + test ( assert, component, target, window ) { const button = target.querySelector( 'button' ); const event = new window.MouseEvent( 'click' ); diff --git a/test/compiler/default-data/_config.js b/test/compiler/default-data/_config.js index 14c30650f8..26b3554f9f 100644 --- a/test/compiler/default-data/_config.js +++ b/test/compiler/default-data/_config.js @@ -1,5 +1,3 @@ -import * as assert from 'assert'; - export default { html: '

Hello world!

' }; diff --git a/test/compiler/each-block-containing-if/_config.js b/test/compiler/each-block-containing-if/_config.js index 5a0e9f54c9..0b783a1cf1 100644 --- a/test/compiler/each-block-containing-if/_config.js +++ b/test/compiler/each-block-containing-if/_config.js @@ -1,7 +1,5 @@ -import * as assert from 'assert'; - export default { - test ( component, target ) { + test ( assert, component, target ) { const items = component.get( 'items' ); items.forEach( item => item.completed = false ); diff --git a/test/compiler/each-block/_config.js b/test/compiler/each-block/_config.js index c5a7041755..959bf88c04 100644 --- a/test/compiler/each-block/_config.js +++ b/test/compiler/each-block/_config.js @@ -1,11 +1,9 @@ -import * as assert from 'assert'; - export default { data: { animals: [ 'alpaca', 'baboon', 'capybara' ] }, html: '

alpaca

baboon

capybara

', - test ( component, target ) { + test ( assert, component, target ) { component.set({ animals: [ 'alpaca', 'baboon', 'caribou', 'dogfish' ] }); assert.equal( target.innerHTML, '

alpaca

baboon

caribou

dogfish

' ); component.set({ animals: [] }); diff --git a/test/compiler/each-blocks-nested-b/_config.js b/test/compiler/each-blocks-nested-b/_config.js index e3b5bc3d7e..806284ef2d 100644 --- a/test/compiler/each-blocks-nested-b/_config.js +++ b/test/compiler/each-blocks-nested-b/_config.js @@ -29,7 +29,7 @@ export default { ] }, html: `

animals: aardvark

animals: buffalo

animals: chinchilla

countries: albania

countries: brazil

countries: china

people: alice

people: bob

people: carol

people: dave

`, - test ( component, target ) { + test ( assert, component, target ) { // TODO } }; diff --git a/test/compiler/each-blocks-nested/_config.js b/test/compiler/each-blocks-nested/_config.js index a0f2190346..bc0064d8e8 100644 --- a/test/compiler/each-blocks-nested/_config.js +++ b/test/compiler/each-blocks-nested/_config.js @@ -4,7 +4,7 @@ export default { rows: [ 1, 2, 3 ] }, html: `
a, 1
a, 2
a, 3
b, 1
b, 2
b, 3
c, 1
c, 2
c, 3
`, - test ( component, target ) { + test ( assert, component, target ) { // TODO } }; diff --git a/test/compiler/event-handler-custom/_config.js b/test/compiler/event-handler-custom/_config.js index c7b4d8cfa1..ab4a20e844 100644 --- a/test/compiler/event-handler-custom/_config.js +++ b/test/compiler/event-handler-custom/_config.js @@ -1,8 +1,6 @@ -import * as assert from 'assert'; - export default { html: '', - test ( component, target, window ) { + test ( assert, component, target, window ) { const event = new window.MouseEvent( 'click', { clientX: 42, clientY: 42 diff --git a/test/compiler/event-handler-removal/_config.js b/test/compiler/event-handler-removal/_config.js index 6aef8b1fdc..91bc0452a5 100644 --- a/test/compiler/event-handler-removal/_config.js +++ b/test/compiler/event-handler-removal/_config.js @@ -1,10 +1,8 @@ -import * as assert from 'assert'; - // TODO gah, JSDOM appears to behave differently to real browsers here... probably need to raise an issue export default { html: '', - test ( component ) { + test ( assert, component ) { component.refs.input.focus(); // this should NOT trigger blur event diff --git a/test/compiler/event-handler/_config.js b/test/compiler/event-handler/_config.js index 13cec519da..5fb7f6bc86 100644 --- a/test/compiler/event-handler/_config.js +++ b/test/compiler/event-handler/_config.js @@ -1,8 +1,6 @@ -import * as assert from 'assert'; - export default { html: '\n\n', - test ( component, target, window ) { + test ( assert, component, target, window ) { const button = target.querySelector( 'button' ); const event = new window.MouseEvent( 'click' ); diff --git a/test/compiler/events-custom/_config.js b/test/compiler/events-custom/_config.js index 226fc3534f..ed86a9300d 100644 --- a/test/compiler/events-custom/_config.js +++ b/test/compiler/events-custom/_config.js @@ -1,7 +1,5 @@ -import * as assert from 'assert'; - export default { - test ( component ) { + test ( assert, component ) { let count = 0; const expected = { x: 1 }; diff --git a/test/compiler/events-lifecycle/_config.js b/test/compiler/events-lifecycle/_config.js index 24b9a03529..3a9677fca1 100644 --- a/test/compiler/events-lifecycle/_config.js +++ b/test/compiler/events-lifecycle/_config.js @@ -1,7 +1,5 @@ -import * as assert from 'assert'; - export default { - test ( component ) { + test ( assert, component ) { let count = 0; component.on( 'teardown', function () { diff --git a/test/compiler/hello-world/_config.js b/test/compiler/hello-world/_config.js index 4c3701271d..3771a01231 100644 --- a/test/compiler/hello-world/_config.js +++ b/test/compiler/hello-world/_config.js @@ -1,12 +1,10 @@ -import * as assert from 'assert'; - export default { data: { name: 'world' }, html: '

Hello world!

', - test ( component, target ) { + test ( assert, component, target ) { component.set({ name: 'everybody' }); assert.equal( target.innerHTML, '

Hello everybody!

' ); component.teardown(); diff --git a/test/compiler/if-block-else/_config.js b/test/compiler/if-block-else/_config.js index 9c0e9061be..37df9e0daf 100644 --- a/test/compiler/if-block-else/_config.js +++ b/test/compiler/if-block-else/_config.js @@ -1,12 +1,10 @@ -import * as assert from 'assert'; - export default { data: { foo: true, bar: false }, html: '

foo

\n\n

not bar

', - test ( component, target ) { + test ( assert, component, target ) { component.set({ foo: false }); assert.equal( target.innerHTML, '

not foo

\n\n

not bar

' ); component.set({ bar: true }); diff --git a/test/compiler/if-block/_config.js b/test/compiler/if-block/_config.js index ba75107b36..f8014c5c9a 100644 --- a/test/compiler/if-block/_config.js +++ b/test/compiler/if-block/_config.js @@ -1,11 +1,9 @@ -import * as assert from 'assert'; - export default { data: { visible: true }, html: '

i am visible

', - test ( component, target ) { + test ( assert, component, target ) { component.set({ visible: false }); assert.equal( target.innerHTML, '' ); component.set({ visible: true }); diff --git a/test/compiler/inline-expressions/_config.js b/test/compiler/inline-expressions/_config.js index e6033aa6cf..8037302ac8 100644 --- a/test/compiler/inline-expressions/_config.js +++ b/test/compiler/inline-expressions/_config.js @@ -1,12 +1,10 @@ -import * as assert from 'assert'; - export default { data: { a: 1, b: 2 }, html: '

1 + 2 = 3

', - test ( component, target ) { + test ( assert, component, target ) { component.set({ a: 3, b: 4 }); assert.equal( target.innerHTML, '

3 + 4 = 7

' ); } diff --git a/test/compiler/lifecycle-events/_config.js b/test/compiler/lifecycle-events/_config.js index 4e9c18ed70..457d888b06 100644 --- a/test/compiler/lifecycle-events/_config.js +++ b/test/compiler/lifecycle-events/_config.js @@ -1,7 +1,5 @@ -import * as assert from 'assert'; - export default { - test ( component ) { + test ( assert, component ) { assert.deepEqual( component.events, [ 'render' ]); component.teardown(); assert.deepEqual( component.events, [ 'render', 'teardown' ]); diff --git a/test/compiler/refs/_config.js b/test/compiler/refs/_config.js index 4cab4660da..e8070770ba 100644 --- a/test/compiler/refs/_config.js +++ b/test/compiler/refs/_config.js @@ -1,8 +1,6 @@ -import * as assert from 'assert'; - export default { html: '', - test ( component, target ) { + test ( assert, component, target ) { const canvas = target.querySelector( 'canvas' ); assert.equal( canvas, component.refs.foo ); } diff --git a/test/compiler/svg/_config.js b/test/compiler/svg/_config.js index f9f1492631..44f6c8aa71 100644 --- a/test/compiler/svg/_config.js +++ b/test/compiler/svg/_config.js @@ -1,5 +1,3 @@ -import * as assert from 'assert'; - export default { data: { x: 0, @@ -8,7 +6,7 @@ export default { height: 100 }, html: ``, - test ( component, target ) { + test ( assert, component, target ) { const svg = target.querySelector( 'svg' ); const rect = target.querySelector( 'rect' ); diff --git a/test/test.js b/test/test.js index 4a633c9296..d748feb092 100644 --- a/test/test.js +++ b/test/test.js @@ -1,6 +1,6 @@ import { compile } from '../compiler/index.js'; import parse from '../compiler/parse/index.js'; -import * as assert from 'assert'; +import assert from 'assert'; import * as path from 'path'; import * as fs from 'fs'; import jsdom from 'jsdom'; @@ -141,7 +141,7 @@ describe( 'svelte', () => { } if ( config.test ) { - config.test( component, target, window ); + config.test( assert, component, target, window ); } else { component.teardown(); assert.equal( target.innerHTML, '' );