@interface PluginManagerTest : XCTestCase

@end

@implementation PluginManagerTest

- (void)testInit
{
  
  PluginManager *manager = [PluginManager.alloc initWithPluginPath:@"~/Work/bitbar/BitBar/BitBarTests/TestPlugins"];
  XCTAssert([manager.path isEqualToString:[@"~/Work/bitbar/BitBar/BitBarTests/TestPlugins" stringByStandardizingPath]]);
  
}

- (void)testPluginFiles {
  
  PluginManager *manager = [PluginManager.alloc initWithPluginPath:@"~/Work/bitbar/BitBar/BitBarTests/TestPlugins"];
  
  NSArray *pluginFiles = manager.plugins;
  XCTAssertEqual((NSUInteger)3, [pluginFiles count], @"pluginFiles count");
  
}

- (void)testPlugins {
  
  PluginManager *manager = [PluginManager.alloc initWithPluginPath:@"~/Work/bitbar/BitBar/BitBarTests/TestPlugins"];

  NSArray *plugins = manager.plugins;
  
  XCTAssertEqual((NSUInteger)3, [plugins count], @"plugins count");
  Plugin *one = [plugins objectAtIndex:0];
  
  XCTAssertNotNil(one, @"one shouldn't be nil");
  XCTAssertEqual(manager, one.manager, @"manager");
  XCTAssert([one.name isEqualToString:@"one.10s.sh"], @"name");
  XCTAssert([one.path isEqualToString:[[@"~/Work/bitbar/BitBar/BitBarTests/TestPlugins" stringByStandardizingPath] stringByAppendingPathComponent:@"one.10s.sh"]], @"path");
  
}

- (void)testStatusBar {
  
  PluginManager *manager = [PluginManager.alloc initWithPluginPath:@"~/Work/bitbar/BitBar/BitBarTests/TestPlugins"];

  NSStatusBar *statusBar = manager.statusBar;
  XCTAssertNotNil(statusBar, @"statusBar");
  XCTAssertEqual([NSStatusBar systemStatusBar], statusBar, @"statusBar should default to system one");
 
  // set on explicitly
  NSStatusBar *newBar = NSStatusBar.new;
  manager.statusBar = newBar;
  XCTAssertEqual(newBar, manager.statusBar);
  
}

@end
