Skip to content

Commit

Permalink
Merge pull request #14 from Nimblesite/commonunittest
Browse files Browse the repository at this point in the history
Add a Unit Test Back and Run in Actions
  • Loading branch information
MelbourneDeveloper authored Sep 18, 2024
2 parents 06863b5 + 5fba405 commit 9faab3b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ jobs:
cd $GITHUB_WORKSPACE
done
- name: Run Tests
- name: Run Common Tests
run: |
cd charts_common
flutter test --coverage
cd $GITHUB_WORKSPACE
- name: Run UI Tests
run: |
cd charts_flutter
flutter test --coverage
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ charts_flutter/test/widget_tests/failures/
charts_flutter/test/example_widget_tests/failures/

charts_flutter/test/.DS_Store

charts_common/coverage/

charts_common/.DS_Store

charts_common/test/chart/.DS_Store
46 changes: 46 additions & 0 deletions charts_common/test/chart/layout/layout_manager_impl_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2018 the Charts project authors. Please see the AUTHORS file
// for details.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:nimble_charts_common/src/chart/layout/layout_config.dart';
import 'package:nimble_charts_common/src/chart/layout/layout_manager_impl.dart';

import 'package:test/test.dart';

void main() {
test('default layout', () {
final layout = LayoutManagerImpl()..measure(400, 300);

expect(layout.marginTop, equals(0));
expect(layout.marginRight, equals(0));
expect(layout.marginBottom, equals(0));
expect(layout.marginLeft, equals(0));
});

test('all fixed margin', () {
final layout = LayoutManagerImpl(
config: LayoutConfig(
topSpec: MarginSpec.fixedPixel(12),
rightSpec: MarginSpec.fixedPixel(11),
bottomSpec: MarginSpec.fixedPixel(10),
leftSpec: MarginSpec.fixedPixel(9),
),
)..measure(400, 300);

expect(layout.marginTop, equals(12));
expect(layout.marginRight, equals(11));
expect(layout.marginBottom, equals(10));
expect(layout.marginLeft, equals(9));
});
}
6 changes: 5 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
cd charts_flutter
cd charts_common

flutter test --update-goldens --coverage

cd ../charts_flutter

flutter test --update-goldens --coverage

Expand Down

0 comments on commit 9faab3b

Please sign in to comment.