Skip to content

Commit

Permalink
Add basic DataContext unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueWinds committed Oct 22, 2021
1 parent 155fb32 commit 6601c42
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 3 deletions.
59 changes: 59 additions & 0 deletions packages/data-context/__snapshots__/data-context.spec.ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
exports['@packages/data-context initializeData should initialize 1'] = {
"shellConfig": {
"launchOptions": {},
"launchArgs": {},
"appApi": {},
"authApi": {},
"projectApi": {}
},
"config": {
"launchOptions": {},
"launchArgs": {},
"appApi": {},
"authApi": {},
"projectApi": {}
},
"_coreData": {
"baseError": null,
"dev": {
"refreshState": null
},
"app": {
"activeTestingType": null,
"navItem": "settings",
"browsers": {},
"projects": [],
"activeProject": null,
"isInGlobalMode": false,
"isAuthBrowserOpened": false
},
"wizard": {
"chosenTestingType": null,
"chosenBundler": null,
"chosenFramework": null,
"chosenLanguage": "js",
"chosenManualInstall": false,
"currentStep": "welcome",
"allBundlers": [
{
"type": "webpack",
"name": "Webpack",
"package": "@cypress/webpack-dev-server"
},
{
"type": "vite",
"name": "Vite",
"package": "@cypress/vite-dev-server"
}
],
"history": [
"welcome"
],
"chosenBrowser": null
},
"user": null,
"electron": {
"browserWindow": null
}
}
}
42 changes: 39 additions & 3 deletions packages/data-context/test/unit/data-context.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,43 @@
import { expect } from 'chai'
import { DataContext } from '@packages/data-context'
import snapshot from 'snap-shot-it'

describe('@packages/data-context unit', () => {
it('has a sample test', () => {
expect(1).to.eq(1)
const makeDataContext = (options) => {
return new DataContext({
launchOptions: {},
launchArgs: {},
appApi: {
getBrowsers: () => ({}),
},
authApi: {},
projectApi: {
getProjectRootsFromCache: () => ([]),
},
...options,
})
}

describe('@packages/data-context', () => {
describe('initializeData', () => {
it('should initialize', async () => {
const context = makeDataContext()

await context.initializeData()
snapshot(context)
})

it('should skip first wizard step when given a testingType', async () => {
const context = makeDataContext({
launchArgs: {
testingType: 'e2e',
},
})

await context.initializeData()
expect(context._coreData.wizard).to.contain({
chosenTestingType: 'e2e',
currentStep: 'initializePlugins',
})
})
})
})

0 comments on commit 6601c42

Please sign in to comment.