-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add deletedns unit test * fix removeDns() * use double quotes * fix editor with lint --------- Co-authored-by: pablomendezroyo <[email protected]>
- Loading branch information
1 parent
d5d60bf
commit 0cb21ad
Showing
2 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import "mocha"; | ||
import { expect } from "chai"; | ||
import { ComposeEditor } from "../../src/index.js"; | ||
import { Compose } from "@dappnode/types"; | ||
|
||
describe("ComposeServiceEditor", function () { | ||
describe("removeDns()", function () { | ||
it("should remove the dns field from the service", function () { | ||
// Create a mock compose object | ||
const mockCompose: Compose = { | ||
version: "3", | ||
services: { | ||
myservice: { | ||
image: "myimage", | ||
dns: "8.8.8.8", | ||
environment: [] | ||
} | ||
} | ||
}; | ||
|
||
// Create a ComposeEditor instance with the mock compose | ||
const composeEditor = new ComposeEditor(mockCompose); | ||
|
||
// Get the service editor for 'myservice' | ||
const serviceEditor = composeEditor.services()["myservice"]; | ||
|
||
// Ensure dns field is present before removal | ||
expect(serviceEditor.get().dns).to.deep.equal("8.8.8.8"); | ||
|
||
// Call removeDns() | ||
serviceEditor.removeDns(); | ||
|
||
// Get the updated service | ||
const updatedService = serviceEditor.get(); | ||
|
||
// Verify that the dns field is removed | ||
expect(updatedService.dns).to.be.undefined; | ||
|
||
// Output the compose and check that dns is not present | ||
const outputCompose = composeEditor.output(); | ||
expect(outputCompose.services["myservice"].dns).to.be.undefined; | ||
|
||
// Ensure other fields remain unchanged | ||
expect(outputCompose.services["myservice"].image).to.equal("myimage"); | ||
}); | ||
}); | ||
}); |