configuration_test.dart 2.07 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'dart:io';
6 7

import 'package:snippets/configuration.dart';
8
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
9 10 11

void main() {
  group('Configuration', () {
12
    late Configuration config;
13 14

    setUp(() {
15
      config = Configuration(flutterRoot: Directory('/flutter sdk'));
16 17
    });
    test('config directory is correct', () async {
18 19
      expect(config.configDirectory.path,
          matches(RegExp(r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config')));
20 21 22
    });
    test('output directory is correct', () async {
      expect(config.outputDirectory.path,
23
          matches(RegExp(r'[/\\]flutter sdk[/\\]dev[/\\]docs[/\\]doc[/\\]snippets')));
24 25 26
    });
    test('skeleton directory is correct', () async {
      expect(config.skeletonsDirectory.path,
27
          matches(RegExp(r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons')));
28 29 30
    });
    test('templates directory is correct', () async {
      expect(config.templatesDirectory.path,
31
          matches(RegExp(r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]templates')));
32
    });
33 34
    test('html skeleton file for sample is correct', () async {
      expect(
35
          config.getHtmlSkeletonFile(SnippetType.snippet).path,
36
          matches(RegExp(
37
              r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]snippet.html')));
38 39
    });
    test('html skeleton file for app with no dartpad is correct', () async {
40
      expect(
41
          config.getHtmlSkeletonFile(SnippetType.sample).path,
42
          matches(RegExp(
43
              r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]sample.html')));
44
    });
45 46
    test('html skeleton file for app with dartpad is correct', () async {
      expect(
47
          config.getHtmlSkeletonFile(SnippetType.sample, showDartPad: true).path,
48
          matches(RegExp(
49
              r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]dartpad-sample.html')));
50
    });
51 52
  });
}