Skip to content

Commit

Permalink
test: add test for optionsPath
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza committed Apr 8, 2021
1 parent 003752e commit 390006e
Show file tree
Hide file tree
Showing 13 changed files with 566 additions and 664 deletions.
4 changes: 1 addition & 3 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { setupTest, getNuxt, get, url } from '@nuxt/test-utils'
describe('basic', () => {
setupTest({
server: true,
fixture: 'fixture/basic',
configFile: 'nuxt.config.ts'
fixture: 'fixture/basic'
})

test('echo should be defined', async () => {
/* @ts-ignore */
const window = await getNuxt().renderAndGetWindow(url('/'))
expect(window.$nuxt.$echo).toBeDefined()
})
Expand Down
18 changes: 18 additions & 0 deletions test/custom-options-path.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { setupTest, getNuxt, get, url } from '@nuxt/test-utils'

describe('custom-options-path', () => {
setupTest({
server: true,
fixture: 'fixture/custom-options-path'
})

test('onAfterConnect should be defined', async () => {
const window = await getNuxt().renderAndGetWindow(url('/'))
expect(window.$nuxt.$echo.options.onAfterConnect).toBeDefined()
})

test('render', async () => {
const { body } = await get('/')
expect(body).toContain('Works!')
})
})
5 changes: 5 additions & 0 deletions test/fixture/custom-options-path/laravel-echo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
onAfterConnect () {
//
}
}
13 changes: 13 additions & 0 deletions test/fixture/custom-options-path/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

import { NuxtConfig } from '@nuxt/types'

export default <NuxtConfig> {
buildModules: [
'@nuxt/typescript-build',
'../../../src/module.ts'
],

echo: {
optionsPath: './laravel-echo.ts'
}
}
5 changes: 5 additions & 0 deletions test/fixture/custom-options-path/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
Works!
</div>
</template>
3 changes: 3 additions & 0 deletions test/fixture/custom-options-path/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../../tsconfig.json"
}
5 changes: 5 additions & 0 deletions test/fixture/options-path/app/laravel-echo/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
onBeforeConnect () {
//
}
}
9 changes: 9 additions & 0 deletions test/fixture/options-path/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import { NuxtConfig } from '@nuxt/types'

export default <NuxtConfig> {
buildModules: [
'@nuxt/typescript-build',
'../../../src/module.ts'
]
}
5 changes: 5 additions & 0 deletions test/fixture/options-path/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
Works!
</div>
</template>
3 changes: 3 additions & 0 deletions test/fixture/options-path/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../../tsconfig.json"
}
18 changes: 18 additions & 0 deletions test/options-path.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { setupTest, getNuxt, get, url } from '@nuxt/test-utils'

describe('options-path', () => {
setupTest({
server: true,
fixture: 'fixture/options-path'
})

test('onBeforeConnect should be defined', async () => {
const window = await getNuxt().renderAndGetWindow(url('/'))
expect(window.$nuxt.$echo.options.onBeforeConnect).toBeDefined()
})

test('render', async () => {
const { body } = await get('/')
expect(body).toContain('Works!')
})
})
4 changes: 1 addition & 3 deletions test/with-plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { setupTest, getNuxt, get, url } from '@nuxt/test-utils'
describe('with-plugins', () => {
setupTest({
server: true,
fixture: 'fixture/with-plugins',
configFile: 'nuxt.config.ts'
fixture: 'fixture/with-plugins'
})

test('echo plugin should be defined', async () => {
/* @ts-ignore */
const window = await getNuxt().renderAndGetWindow(url('/'))
expect(window.$nuxt.$echo).toBeDefined()
expect(window.$nuxt.$echo.plugin).toBe(true)
Expand Down
Loading

0 comments on commit 390006e

Please sign in to comment.