-
Notifications
You must be signed in to change notification settings - Fork 2
Add remoteData tests #10
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dcf9d63
add test project
Larocceau ad8ef39
Merge remote-tracking branch 'origin/main' into setup-tests
Larocceau 836bc47
Merge remote-tracking branch 'origin/main' into setup-tests
Larocceau cd5dc18
add tests
Larocceau 6557c94
add fable
Larocceau fd9572e
add build target
Larocceau 3d31eb2
add pipeline action
Larocceau 59a41e7
fix action title
Larocceau 5eb1900
explicitly install npm
Larocceau 620c950
use relative link directly for running npm
Larocceau 3de3c0d
Install node
Larocceau 04df9f9
use correct path
Larocceau 581bb18
Case sensitive 🤬
Larocceau 7bc717d
add npm install
Larocceau 6e2ae8d
formatting
Larocceau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,23 @@ | ||
| name: SAFE meta automated tests | ||
|
|
||
| on: push | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 18 | ||
|
|
||
| - name: Tool Restore | ||
| run: dotnet tool restore | ||
|
|
||
| - name: Test | ||
| working-directory: ./Build | ||
| run: dotnet run --project Build.fsproj -- Test |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| Fake.Core.Target | ||
| Fake.Core.Target | ||
| Fake.JavaScript.Npm |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,129 @@ | ||
| module Client.Tests | ||
|
|
||
| open Fable.Mocha | ||
| open SAFE | ||
|
|
||
| [<RequireQualifiedAccess>] | ||
| type RemoteDataCase = | ||
| | NotStarted | ||
| | LoadingEmpty | ||
| | LoadingPopulated | ||
| | Loaded | ||
|
|
||
| member this.Label = | ||
| match this with | ||
| | NotStarted -> "Not started" | ||
| | LoadingEmpty -> "Loading empty" | ||
| | LoadingPopulated -> "Loading populated" | ||
| | Loaded -> "loaded" | ||
|
|
||
| member this.Example = | ||
| match this with | ||
| | NotStarted -> RemoteData.NotStarted | ||
| | LoadingEmpty -> Loading None | ||
| | LoadingPopulated -> Loading(Some true) | ||
| | Loaded -> RemoteData.Loaded true | ||
|
|
||
| module RemoteDataCase = | ||
| let all = [ | ||
| RemoteDataCase.NotStarted | ||
| RemoteDataCase.LoadingEmpty | ||
| RemoteDataCase.LoadingPopulated | ||
| RemoteDataCase.Loaded | ||
| ] | ||
|
|
||
|
|
||
| let inline testListForAll<'T when 'T: equality> | ||
| title | ||
| (transformation: RemoteData<bool> -> 'T) | ||
| (expectedMaker: RemoteDataCase -> 'T) | ||
| = | ||
|
|
||
| testList | ||
| title | ||
| (all | ||
| |> List.map (fun case -> | ||
| let expected = expectedMaker case | ||
|
|
||
| (fun _ -> Expect.equal (transformation case.Example) expected "") | ||
| |> testCase case.Label)) | ||
|
|
||
| let remoteData = | ||
| testList "RemoteData" [ | ||
| RemoteDataCase.testListForAll "defaultValue" (fun case -> case.DefaultValue false) (function | ||
| | RemoteDataCase.NotStarted | ||
| | RemoteDataCase.LoadingEmpty -> false | ||
| | RemoteDataCase.LoadingPopulated | ||
| | RemoteDataCase.Loaded -> true) | ||
|
|
||
| RemoteDataCase.testListForAll "HasLoaded" (_.HasLoaded) (function | ||
| | RemoteDataCase.NotStarted | ||
| | RemoteDataCase.LoadingEmpty | ||
| | RemoteDataCase.LoadingPopulated -> false | ||
| | RemoteDataCase.Loaded -> true) | ||
|
|
||
| RemoteDataCase.testListForAll "AsOption" (_.AsOption) (function | ||
| | RemoteDataCase.NotStarted | ||
| | RemoteDataCase.LoadingEmpty -> None | ||
| | RemoteDataCase.LoadingPopulated | ||
| | RemoteDataCase.Loaded -> Some true) | ||
|
|
||
| RemoteDataCase.testListForAll "hasStarted" (_.HasStarted) (function | ||
| | RemoteDataCase.NotStarted -> false | ||
| | RemoteDataCase.LoadingEmpty | ||
| | RemoteDataCase.LoadingPopulated | ||
| | RemoteDataCase.Loaded -> true) | ||
|
|
||
| RemoteDataCase.testListForAll "hasData" (_.HasData) (function | ||
| | RemoteDataCase.NotStarted | ||
| | RemoteDataCase.LoadingEmpty -> false | ||
| | RemoteDataCase.LoadingPopulated | ||
| | RemoteDataCase.Loaded -> true) | ||
|
|
||
| RemoteDataCase.testListForAll "isStillLoading" (_.IsStillLoading) (function | ||
| | RemoteDataCase.NotStarted -> false | ||
| | RemoteDataCase.LoadingEmpty | ||
| | RemoteDataCase.LoadingPopulated -> true | ||
| | RemoteDataCase.Loaded -> false) | ||
|
|
||
| RemoteDataCase.testListForAll "isRefresing" (_.IsRefreshing) (function | ||
| | RemoteDataCase.NotStarted -> false | ||
| | RemoteDataCase.LoadingEmpty -> false | ||
| | RemoteDataCase.LoadingPopulated -> true | ||
| | RemoteDataCase.Loaded -> false) | ||
|
|
||
| RemoteDataCase.testListForAll "hasNotStarted" (_.HasNotStarted) (function | ||
| | RemoteDataCase.NotStarted -> true | ||
| | RemoteDataCase.LoadingEmpty | ||
| | RemoteDataCase.LoadingPopulated | ||
| | RemoteDataCase.Loaded -> false) | ||
|
|
||
| RemoteDataCase.testListForAll "map" (_.Map(not)) (function | ||
| | RemoteDataCase.NotStarted -> NotStarted | ||
| | RemoteDataCase.LoadingEmpty -> Loading None | ||
| | RemoteDataCase.LoadingPopulated -> Loading(Some false) | ||
| | RemoteDataCase.Loaded -> Loaded false) | ||
|
|
||
| testList "bind" [ | ||
| RemoteDataCase.testListForAll "toLoaded" (_.Bind(Loaded)) (function | ||
| | RemoteDataCase.NotStarted -> NotStarted | ||
| | RemoteDataCase.LoadingEmpty -> Loading None | ||
| | RemoteDataCase.LoadingPopulated | ||
| | RemoteDataCase.Loaded -> Loaded true) | ||
|
|
||
| RemoteDataCase.testListForAll "toNotStarted" (_.Bind(fun _ -> NotStarted)) (function | ||
| | RemoteDataCase.NotStarted -> NotStarted | ||
| | RemoteDataCase.LoadingEmpty -> Loading None | ||
| | RemoteDataCase.LoadingPopulated | ||
| | RemoteDataCase.Loaded -> NotStarted) | ||
| ] | ||
|
|
||
| RemoteDataCase.testListForAll "startLoading" (_.StartLoading()) (function | ||
| | RemoteDataCase.NotStarted -> Loading None | ||
| | RemoteDataCase.LoadingEmpty -> Loading None | ||
| | RemoteDataCase.LoadingPopulated -> Loading (Some true) | ||
| | RemoteDataCase.Loaded -> Loading (Some true)) | ||
| ] | ||
|
|
||
| [<EntryPoint>] | ||
| let main _ = Mocha.runTests remoteData | ||
This file contains hidden or 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,17 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <RootNamespace>SAFE.Client</RootNamespace> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="Program.fs" /> | ||
| <Content Include="paket.references" /> | ||
| <Content Include="package-lock.json" /> | ||
| <Content Include="package.json" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\src\SAFE.Client\SAFE.Client.fsproj" /> | ||
| </ItemGroup> | ||
| <Import Project="..\..\.paket\Paket.Restore.targets" /> | ||
| </Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.