Skip to content

Commit

Permalink
ALL TESTS PASS!
Browse files Browse the repository at this point in the history
Jest is out. What a day.
  • Loading branch information
cubap committed Jan 25, 2024
1 parent b54a1ea commit e280ec4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6,353 deletions.
8 changes: 4 additions & 4 deletions api/project.js → api/project.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export default class Project {

if (typeof projectID === "string") {
this.id = projectID
this.fetchByID(projectID)
.then(project => this.data = project)
return
}

Expand All @@ -31,8 +29,10 @@ export default class Project {
* @param {String} projectID short hash id for TPEN project
*/

fetchByID(projectID) {
fetch(`/project/${projectID}`)
async loadData() {
return await fetch(`/project/${this.id}`)
.then(response => response.json())
.then(project => this.data = project)
.catch(err=>new Promise.reject(err))
}
}
17 changes: 0 additions & 17 deletions api/project.test.js

This file was deleted.

24 changes: 24 additions & 0 deletions api/project.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Project from "./project.mjs"
import {describe,it} from 'node:test'
import assert from 'node:assert'

describe("Project", () => {
it("should create a project with a this config", () => {
const project = new Project({
name: "Test Project",
email: "[email protected]",
})
assert.equal(project.data.name,"Test Project")
assert.equal(project.data.email,"[email protected]")
})

it("should initialize a project with this id", () => {
const project = new Project("someHash")
assert.equal(project.id,"someHash")
})

it("should fail to find a project with this id", () => {
const project = new Project("someHash")
assert.rejects(project.loadData())
})
})
1 change: 0 additions & 1 deletion jest.config.json

This file was deleted.

Loading

0 comments on commit e280ec4

Please sign in to comment.