Skip to content

Commit

Permalink
fixed: unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Oct 13, 2023
1 parent f20eddc commit f498609
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 37 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"demo": "npm run build && serve",
"cov": "c8 report --reporter=lcov",
"cov-html": "c8 report --reporter=html",
"test": "npm run lint && c8 mocha -r esm -r test/setup.js test/*.spec.js"
"test": "npm run lint && NODE_OPTIONS=\"--loader @riotjs/register\" c8 mocha -r test/setup.js test/*.spec.js"
},
"files": [
"index.d.ts",
Expand Down Expand Up @@ -67,7 +67,6 @@
"chai": "^4.3.10",
"eslint": "^8.51.0",
"eslint-config-riot": "^4.1.1",
"esm": "^3.2.25",
"jsdom": "22.1.0",
"jsdom-global": "3.0.2",
"mocha": "^10.2.0",
Expand Down
6 changes: 3 additions & 3 deletions src/components/route-hoc.riot
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
</template>

<script>
import {route, toRegexp, match, router, createURLStreamPipe} from '../'
import getCurrentRoute from '../get-current-route'
import {route, toRegexp, match, router, createURLStreamPipe} from '../index.js'
import getCurrentRoute from '../get-current-route.js'
import compose from 'cumpa'
const getInitialRouteValue = (pathToRegexp, path, options) => {
Expand Down Expand Up @@ -54,4 +54,4 @@
}
}
</script>
</route-hoc>
</route-hoc>
10 changes: 5 additions & 5 deletions src/components/router-hoc.riot
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<router-hoc>
<script>
import {router} from '../'
import {defer, cancelDefer} from '../util'
import {router} from '../index.js'
import {defer, cancelDefer} from '../util.js'
import {pure, __} from 'riot'
import getCurrentRoute from '../get-current-route'
import setBase from '../set-base'
import getCurrentRoute from '../get-current-route.js'
import setBase from '../set-base.js'
import {panic} from '@riotjs/util/misc'
import {dashToCamelCase} from '@riotjs/util/strings'
import initDomListeners from '../dom'
import initDomListeners from '../dom.js'
const BASE_ATTRIBUTE_NAME = 'base'
const INITIAL_ROUTE = 'initialRoute'
Expand Down
4 changes: 2 additions & 2 deletions src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
RE_ORIGIN,
TARGET_SELF_LINK_ATTRIBUTE,
WINDOW_EVENTS,
} from './constants'
} from './constants.js'
import { add, remove } from 'bianco.events'
import { defaults, router } from 'rawth'
import { getDocument, getHistory, getLocation, getWindow } from './util'
import { getDocument, getHistory, getLocation, getWindow } from './util.js'
import { has } from 'bianco.attr'

const onWindowEvent = () =>
Expand Down
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import route, {
router,
toPath,
toRegexp,
toURL
toURL,
} from 'rawth'
import Route from './components/route-hoc.riot'
import Router from './components/router-hoc.riot'
import getCurrentRoute from './get-current-route'
import initDomListeners from './dom'
import setBase from './set-base'
import getCurrentRoute from './get-current-route.js'
import initDomListeners from './dom.js'
import setBase from './set-base.js'

export {
route,
Expand All @@ -24,5 +24,5 @@ export {
initDomListeners,
setBase,
Router,
Route
Route,
}
4 changes: 2 additions & 2 deletions src/set-base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HASH, SLASH } from './constants'
import { HASH, SLASH } from './constants.js'
import { defaults } from 'rawth'
import { getWindow } from './util'
import { getWindow } from './util.js'

export const normalizeInitialSlash = (str) =>
str[0] === SLASH ? str : `${SLASH}${str}`
Expand Down
4 changes: 2 additions & 2 deletions test/components.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { base, sleep } from './util'
import { base, sleep } from './util.js'
import HistoryRouterApp from './components/history-router-app.riot'
import NestedUpdates from './components/nested-updates.riot'
import RecursiveUpdatesBugRouter from './components/recursive-updates-bug-router.riot'
import { component } from 'riot'
import { expect } from 'chai'
import { router } from '../src'
import { router } from '../src/index.js'

describe('components', function () {
beforeEach(async function () {
Expand Down
2 changes: 1 addition & 1 deletion test/components/history-router-app.riot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</router>

<script>
import { Router, Route } from '../../src'
import { Router, Route } from '../../src/index.js'
import User from './user.riot'
export default {
Expand Down
4 changes: 2 additions & 2 deletions test/components/nested-updates.riot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</router>
<script>
import User from './user.riot'
import { Router, Route } from '../../src'
import { Router, Route } from '../../src/index.js'
export default {
components: {
Expand All @@ -22,4 +22,4 @@
}
}
</script>
</nested-updates>
</nested-updates>
4 changes: 2 additions & 2 deletions test/components/recursive-updates-bug-router.riot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</router>

<script>
import { Router, Route } from '../../src'
import { Router, Route } from '../../src/index.js'
import RecursiveUpdatesBug148 from './recursive-updates-bug148.riot'
export default {
Expand All @@ -28,4 +28,4 @@
}
}
</script>
</recursive-updates-bug-router>
</recursive-updates-bug-router>
6 changes: 3 additions & 3 deletions test/misc.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { base, sleep } from './util'
import { getCurrentRoute, router, setBase } from '../src'
import { base, sleep } from './util.js'
import { getCurrentRoute, router, setBase } from '../src/index.js'
import { expect } from 'chai'
import { normalizeBase } from '../src/set-base'
import { normalizeBase } from '../src/set-base.js'

describe('misc methods', function () {
beforeEach(() => {
Expand Down
5 changes: 1 addition & 4 deletions test/setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { base } from './util'
import { base } from './util.js'
import jsdomGlobal from 'jsdom-global'
import register from '@riotjs/register'
import sinonChai from 'sinon-chai'
import { use } from 'chai'

Expand All @@ -9,5 +8,3 @@ jsdomGlobal(null, {
})

use(sinonChai)

register()
4 changes: 2 additions & 2 deletions test/standalone-hash-dom.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { base, sleep } from './util'
import { route, router, setBase } from '../src'
import { base, sleep } from './util.js'
import { route, router, setBase } from '../src/index.js'
import { expect } from 'chai'
import { spy } from 'sinon'

Expand Down
4 changes: 2 additions & 2 deletions test/standalone-history-dom.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fireEvent, sleep } from './util'
import { initDomListeners, route, setBase } from '../src'
import { fireEvent, sleep } from './util.js'
import { initDomListeners, route, setBase } from '../src/index.js'
import $ from 'bianco.query'
import { expect } from 'chai'
import { spy } from 'sinon'
Expand Down

0 comments on commit f498609

Please sign in to comment.