Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(es6): ⬆️ Upgrade to ESM #880

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

Draft
whizzzkid wants to merge 2 commits into ProtoSchool:main
base: main
Choose a base branch
Loading
from whizzzkid:fix/builds
Draft
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
4 changes: 2 additions & 2 deletions cypress/plugins/index.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const webpack = require('@cypress/webpack-preprocessor')
import webpack from '@cypress/webpack-preprocessor'

module.exports = (on, config) => {
export default (on, config) => {
on('before:browser:launch', (browser = {}, launchOptions) => {
if (browser.name === 'chrome') {
launchOptions.args.push('--disable-dev-shm-usage')
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands/visit-with-mock-data.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const tutorials = require('../../fixtures/tutorials.json')
import tutorials from '../../fixtures/tutorials.json'

Cypress.Commands.add('visitWithMockData', function (url) {
cy.visit(url, {
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
export default {
// All imported modules in your tests should be mocked automatically
// automock: false,

Expand Down
4 changes: 1 addition & 3 deletions jest/helpers/asserts.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ function isExcluded (log) {
}

// add log to snapshot UNLESS it contains an excluded phrase
function assertLogSnapshot (log) {
export function assertLogSnapshot (log) {
if (!isExcluded(log)) {
expect(log).toMatchSnapshot() // expect if log isn't excluded from assertion
}
// do nothing if log is excluded from assertion
}

module.exports = { assertLogSnapshot }
35 changes: 14 additions & 21 deletions jest/helpers/fixtures.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
const api = require('../../src/api')
import { lessons as _lessons, resources as _resources, courses, tutorials } from '../../src/api'

// Creators: create data (tutorials, lessons)
function createTutorial (config = { override: {}, lessons: 0, resources: 0 }) {
export function createTutorial (config = { override: {}, lessons: 0, resources: 0 }) {
const { tutorial, lessons, resources } = generateTutorial(config)
const createdTutorial = api.tutorials.create(tutorial)
const createdTutorial = tutorials.create(tutorial)

for (let i = 0; i < lessons.length; ++i) {
api.lessons.create(api.tutorials.get(createdTutorial.id), lessons[i])
_lessons.create(tutorials.get(createdTutorial.id), lessons[i])
}

resources.forEach(resource => {
api.resources.add(createdTutorial.id, resource)
_resources.add(createdTutorial.id, resource)
})

return api.tutorials.get(createdTutorial.id)
return tutorials.get(createdTutorial.id)
}

// Generators: generate data to be used

function generateTutorial (config = { override: {}, lessons: 0, resources: 0, lessonOverride: {} }) {
const suffix = api.tutorials.getNextTutorialId()
export function generateTutorial (config = { override: {}, lessons: 0, resources: 0, lessonOverride: {} }) {
const suffix = tutorials.getNextTutorialId()

const tutorial = {
title: `New Tutorial (${suffix})`,
Expand Down Expand Up @@ -55,7 +55,7 @@ function generateTutorial (config = { override: {}, lessons: 0, resources: 0, le
}
}

function generateLesson ({ createTutorial = false, override = {} } = {}) {
export function generateLesson ({ createTutorial = false, override = {} } = {}) {
const lesson = {
title: 'Lesson',
type: 'text',
Expand All @@ -64,8 +64,8 @@ function generateLesson ({ createTutorial = false, override = {} } = {}) {
let tutorial

if (createTutorial) {
tutorial = api.tutorials.create(generateTutorial().tutorial)
api.courses.add(tutorial.id)
tutorial = tutorials.create(generateTutorial().tutorial)
courses.add(tutorial.id)
}

return {
Expand All @@ -75,7 +75,7 @@ function generateLesson ({ createTutorial = false, override = {} } = {}) {
}
}

function generateResource ({ createTutorial, override = {} } = {}) {
export function generateResource ({ createTutorial, override = {} } = {}) {
const resource = {
title: 'Resource',
link: 'https://resource.com',
Expand All @@ -86,8 +86,8 @@ function generateResource ({ createTutorial, override = {} } = {}) {
let tutorial

if (createTutorial) {
tutorial = api.tutorials.create(generateTutorial().tutorial)
api.courses.add(tutorial.id)
tutorial = tutorials.create(generateTutorial().tutorial)
courses.add(tutorial.id)
}

return {
Expand All @@ -96,10 +96,3 @@ function generateResource ({ createTutorial, override = {} } = {}) {
expected: { resource, tutorial }
}
}

module.exports = {
createTutorial,
generateTutorial,
generateLesson,
generateResource
}
14 changes: 5 additions & 9 deletions jest/helpers/setup.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
const api = require('../../src/api')
import { courses, tutorials } from '../../src/api'

function restoreData (lastTutorialId) {
const newLastTutorialId = api.tutorials.list.getLatest().id
export function restoreData (lastTutorialId) {
const newLastTutorialId = tutorials.list.getLatest().id

// delete all new tutorials
for (let id = lastTutorialId + 1; id <= newLastTutorialId; id++) {
api.tutorials.remove(id)
api.courses.remove(id)
tutorials.remove(id)
courses.remove(id)
}
}

module.exports = {
restoreData
}
Loading

AltStyle によって変換されたページ (->オリジナル) /